/**
 * Created by Administrator on 2018/11/24.
 */

//$(function () {
//请求站点集合,默认展示返回的第一个站点
//柱状图
var myChartZhu1 = echarts.init(document.getElementById('rightZhu1'));
var myChartZhu2 = echarts.init(document.getElementById('rightZhu2'));
var myChartZhu3 = echarts.init(document.getElementById('rightZhu3'));
var myChartZhu4 = echarts.init(document.getElementById('rightZhu4'));
//燃气使用量占比
var myChart = echarts.init(document.getElementById('gasUseNum'));
//折线图
var myChartData = echarts.init(document.getElementById('dataZhu'));
var myChartMonth = echarts.init(document.getElementById('monthZhu'));
var myChartYear = echarts.init(document.getElementById('yearZhu'));
//扇形图
var myChartDataBing = echarts.init(document.getElementById('dataShan'));
var myChartMonthBing = echarts.init(document.getElementById('monthShan'));
var myChartYearBing = echarts.init(document.getElementById('yearShan'));
//myChart.setOption(initChartBing([30, 80], ['50%', 150], [{
//	value: 10,
//	name: 'rose1'
//}]));
var siteOne;
ajaxGet({
	url: 'site/getListAll',
	async: '1',
	successFull: function(res) {
		siteOne = res[0].siteName;
	},
	errCallBack: function(res) {
		siteOne = res[0].siteName
	}
});
console.log(siteOne)
$("#siteNameGas").html(siteOne);
var time = (new Date).getTime() - 24 * 60 * 60 * 1000;
var yesday = new Date(time); // 获取的是前一天日期
yesday = yesday.getFullYear() + "-" + (yesday.getMonth() > 9 ? (yesday.getMonth() + 1) : "0" + (yesday.getMonth() + 1)) + "-" + (yesday.getDate() > 9 ? (yesday.getDate()) : "0" + (yesday.getDate())); //字符串拼接转格式：例如2018-08-19;
function getNowFormatDate() {
	var date = new Date();
	var seperator1 = "-";
	var year = date.getFullYear();
	var month = date.getMonth() + 1;
	var strDate = date.getDate();
	if(month >= 1 && month <= 9) {
		month = "0" + month;
	}
	if(strDate >= 0 && strDate <= 9) {
		strDate = "0" + strDate;
	}
	var currentdate = year + seperator1 + month + seperator1 + strDate;
	return currentdate;
};
//function getLastDay(){
	var dates = new Date();
	var years = dates.getFullYear();
	var months = dates.getMonth() + 1;
	var lastDay= new Date(years,months,0);
	var days = lastDay.getDate();
	days = days < 10 ? '0'+days : days;
	months = months < 10 ? '0'+months : months;
//}
console.log(getNowFormatDate())
layui.use(['table', 'form', 'layer'], function() {
	ajaxGet({
		url: 'home/getSiteTypeReport',
		successFull: function(res) {},
		errCallBack: function(res) {
			console.log(res)
			$.each(res, function(i, item) {
				switch(item.siteType) {
					case 0:
						$("#mian").html(item.siteNum);
						console.log(item.siteType)
						break;
					case 1:
						$("#site").html(item.siteNum);
						console.log(item.siteType)
						break;
					case 2:
						$("#LNG").html(item.siteNum);
						console.log(item.siteType)
						break;
					case 3:
						$("#chang").html(item.siteNum);
						console.log(item.siteType)
						break;
					case 4:
						$("#user").html(item.siteNum);
						console.log(item.siteType)
						break;
				}
			});
		}
	});
	defulatSiteGas(1, siteOne);
	defulatSiteGas(2, siteOne);
	defulatSiteGas(3, siteOne);
	//	燃气使用量占比
	function useGasPosi(siteName) {
		ajaxGet({
			url: 'home/getStandardConditionSum',
			data: {
				siteName: siteName
			},
			successFull: function(res) {
				if(res != null) {
					$("#gasNumber").html(res)
				} else {
					$("#gasNumber").html(0)
				}
			},
			errCallBack: function(res) {
				if(res != null) {
					$("#gasNumber").html(res);
					$("#gasSueNum").html(res);
				} else {
					$("#gasNumber").html(0);
					$("#gasSueNum").html(0);
				}
			}
		});
	};
	useGasPosi(siteOne);
	//		各公司使用量 --今天
	function useGasToday(siteName) {
		ajaxGet({
			url: 'home/getActualAmountReport',
			data: {
				siteName: siteName,
				startTime: getNowFormatDate(),
				endTime: getNowFormatDate(),
			},
			successFull: function(res) {

			},
			errCallBack: function(res) {
				console.log(res)
				if(res.length != 0) {
					var data1 = [],
						data2 = [],
						data3 = [];
					$.each(res, function(i, item) {
						data1.push(item.companyName);
						data2.push(item.dayActualAmount);
						data3.push({
							name: item.companyName,
							value: item.dayActualAmount
						})
						myChartZhu1.setOption(initEchartsRight('80%', '80%', '35', '5', data1, data2));
						myChart.setOption(initChartBing([30, 80], ['50%', 150], data3));
					})
				} else {
					myChartZhu1.setOption(initEchartsRight('80%', '80%', '35', '5', ["城市燃气", "电厂燃气"], [0, 0]));
					myChart.setOption(initChartBing([30, 80], ['50%', 150], [{
						name: '0',
						value: '0'
					}, {
						name: '0',
						value: '0'
					}]));
				}

			}
		});
	}
	useGasToday(siteOne);
	//		各公司计划量--今天
	function usePlanToday(siteName) {
		ajaxGet({
			url: 'home/getPlanAmountReport',
			data: {
				siteName: siteName,
				startTime: getNowFormatDate(),
				endTime: getNowFormatDate(),
			},
			successFull: function(res) {

			},
			errCallBack: function(res) {
				//console.log(res)
				if(res.length != 0) {
					var data1 = [],
						data2 = [];
					$.each(res, function(i, item) {
						data1.push(item.companyName);
						data2.push(item.dayPlanAmount);
					});
					myChartZhu2.setOption(initEchartsRight('80%', '80%', '35', '5', data1, data2));
				} else {
					myChartZhu2.setOption(initEchartsRight('80%', '80%', '35', '5', ["城市燃气", "电厂燃气"], [0, 0]));
				};

			}
		});
	}
	usePlanToday(siteOne);
	//		各公司使用量--昨天
	function useGasyeasToday(siteName) {
		ajaxGet({
			url: 'home/getActualAmountReport',
			data: {
				startTime: yesday,
				endTime: yesday,
				siteName: siteName
			},
			successFull: function(res) {

			},
			errCallBack: function(res) {
				console.log(res)
				if(res.length != 0) {
					var data1 = [],
						data2 = [];
					$.each(res, function(i, item) {
						data1.push(item.companyName);
						data2.push(item.dayActualAmount);
					});
					myChartZhu3.setOption(initEchartsRight('80%', '80%', '35', '5', data1, data2));
				} else {
					myChartZhu3.setOption(initEchartsRight('80%', '80%', '35', '5', ["城市燃气", "电厂燃气"], [0, 0]));
				};

			}
		});
	}
	useGasyeasToday(siteOne);
	//		各公司计划量--昨天
	function userPlanYeastoday(siteName) {
		ajaxGet({
			url: 'home/getPlanAmountReport',
			data: {
				siteName: siteName,
				startTime: yesday,
				endTime: yesday,
			},
			successFull: function(res) {

			},
			errCallBack: function(res) {
				//console.log(res)
				if(res.length != 0) {
					var data1 = [],
						data2 = [];
					$.each(res, function(i, item) {
						data1.push(item.companyName);
						data2.push(item.dayPlanAmount);
					});
					myChartZhu4.setOption(initEchartsRight('80%', '80%', '35', '5', data1, data2));
				} else {
					myChartZhu4.setOption(initEchartsRight('80%', '80%', '35', '5', ["城市燃气", "电厂燃气"], [0, 0]));
				}

			}
		});
	}
	userPlanYeastoday(siteOne);
	//当日燃气价格
	ajaxGet({
		url: 'home/getPriceByUnit',
		data: {
			unit: 2,
		},
		successFull: function(res) {
			$("#money").html(res + "元");
		},
		errCallBack: function(res) {
			$("#money").html(res + "元/m3");
		}
	});
	//输差
	function sendGas(siteName) {
		ajaxGet({
			url: 'home/getWastageRater',
			data: {
				siteName: siteName
			},
			successFull: function(res) {
				$("#sendGas").html(res + '%');
			},
			errCallBack: function(res) {
				console.log(res);
				$("#sendGas").html(res + '%');
			}
		});
	}
	sendGas(siteOne);
});
//底部中间扇形图集合
//myChartDataBing.setOption(initChartBing([10, 30], ['50%', 80], [{
//	value: 10,
//	name: 'rose1'
//}]));
//折线图
function initEchartsline(data, datax) {
	return option = {
		tooltip: {
			trigger: 'axis'
		},
		xAxis: [{
			type: 'category',
			splitLine: {
				show: false
			},
			boundaryGap: false,
			axisLabel: {
				textStyle: {
					color: '#fff', //坐标值得具体的颜色

				}
			},
			data: datax
		}],
		yAxis: [{
			type: 'value',
			splitLine: {
				show: false
			},
			axisLabel: {
				textStyle: {
					color: '#fff', //坐标值得具体的颜色

				}
			}
		}],
		grid: {
			width: '60%',
			height: '80%',
			x: 45,
			y: 5,
			borderWidth: '0'
		},
		series: [{
			type: '',
			name: '用气量',
			type: 'line',
			smooth: true,
			itemStyle: {
				normal: {
					areaStyle: {
						type: 'default',
						color: 'rgba(0,215,213,0.4)'
					},
					color: '#00D7D5',
				}
			},
			data: data
		}]
	};

}
//柱状图
function initEchartsRight(width, height, x, y, x_text, zhu_tex) {
	return option = {
		tooltip: {
			trigger: 'axis'
		},
		grid: {
			width: width,
			height: height,
			x: x,
			y: y,
			borderWidth: '0'
		},
		xAxis: [{
			splitLine: {
				show: false
			},
			type: 'category',
			data: x_text,
			axisLabel: {
				textStyle: {
					color: '#fff', //坐标值得具体的颜色
				}
			}
		}],
		yAxis: [{
			type: 'value',
			splitLine: {
				show: false
			},
			axisLabel: {
				textStyle: {
					color: '#fff', //坐标值得具体的颜色

				}
			}
		}],
		series: [{
				data: zhu_tex,
			},
			{
				type: 'bar',
				name: '使用量',
				type: 'bar',
				data: zhu_tex,
				barWidth: 20,
			}
		]
	}
}

//饼图
function initChartBing(radius, center, data) {
	return optionBing = {
		tooltip: {
			trigger: 'item',
			formatter: "{a} <br/>{b} : {c} ({d}%)"
		},
		series: [{
			type: 'pie',
			radius: radius,
			center: center,
			roseType: 'area',
			data: data
		}]
	};
};
var effect = {
	show: true,
	//    scaleSize: require('zrender/tool/env').canvasSupported ? 1 : 2,
	period: 30, // 运动周期，无单位，值越大越慢
	color: '#fff',
	shadowColor: 'rgba(220,220,220,0.4)',
	shadowBlur: 2
};

function itemStyle(idx) {
	return {
		normal: {
			color: '#fff',
			borderWidth: 0.5,
			borderColor: ['rgba(30,144,255,1)', 'lime'][idx],
			lineStyle: {
				type: 'solid'
			}
		}
	}
};
//		站点信息集合
var myChartMap = echarts.init(document.getElementById('mapMark'));
var optionMapline = {
	backgroundColor: 'rgba(16,37,89,0)',
	color: ['#2756a6', 'lime'],
	tooltip: {
		trigger: 'item',
		formatter: '{b}'
	},
	series: [{
		name: '站点',
		type: 'map',
		hoverable: false,
		mapType: 'china',
		itemStyle: {
			normal: {
				borderColor: 'rgba(100,149,237,1)',
				borderWidth: 0.5,
				areaStyle: {
					color: '#2756a6'
				}
			}
		},
		data: [],
	}, ]
};
//站点网图线
ajaxGet({
	url: 'home/getCircuitSiteReport',
	successFull: function(lineres) {
		//console.log(res);
	},
	errCallBack: function(lineres) {
		//console.log(lineres);
		//站点集合
		ajaxGet({
			url: 'site/getListAll',
			successFull: function(res) {
				//console.log(res);
				addMapData(lineres, res);
			},
			errCallBack: function(res) {
				//console.log(res);
				addMapData(lineres, res);
			}
		});
	}
});

function addMapData(lineres, siteres) {
	var linedata = {
		name: '站点',
		type: 'map',
		mapType: 'china',
		itedmStyle: {
			normal: {
				borderColor: 'rgba(100,149,237,1)',
				borderWidth: 0.5,
				areaStyle: {
					color: '#2756a6'
				}
			}
		},
		data: [],
		markLine: {
			symbol: ['circle', 'circle'],
			symbolSize: 1,
			effect: effect,
			clickable: 'true',
			itemStyle: itemStyle(1),
			smooth: true,
			data: []
		},
		geoCoord: {}
	};
	var markdata = {
		name: '站点',
		type: 'map',
		mapType: 'china',
		itedmStyle: {
			normal: {
				borderColor: 'rgba(100,149,237,1)',
				borderWidth: 0.5,
				areaStyle: {
					color: '#2756a6'
				}
			}
		},
		data: [],
		markPoint: {
			symbol: 'emptyCircle',
			symbolSize: function(v) {
				return 4 + v / 100
			},
			effect: {
				show: true,
				shadowBlur: 0,
				color: 'rgba(245,128,32,0.5)'
			},
			itemStyle: {
				normal: {
					label: {
						show: false
					}
				},
				emphasis: {
					label: {
						position: 'top'
					}
				}
			},
			smooth: true,
			data: []
		},
		geoCoord: {}
	};
	if(lineres != null) {
		$.each(siteres, function(i, item) {
			$.each(lineres, function(j, child) {
				//				linedata.markLine.data.push([{name: item.siteId}, {name: item.endSiteId}]);
				if(item.id == child.siteId) {
					child.siteName = item.siteName;
				};
				if(item.id == child.endSiteId) {
					child.endSiteName = item.siteName;
				}
			});
		});
		console.log(lineres)
		$.each(lineres, function(i, item) {
			linedata.markLine.data.push([{
				name: item.siteName
			}, {
				name: item.endSiteName
			}]);
		});
	};
	if(siteres != null) {
		var markName = [];
		var markgeoCoord = {};
		$.map(siteres, function(item) {
			console.log(typeof item.siteLongitude);
			item.siteLongitude = Number(item.siteLongitude);
			item.siteLatitude = Number(item.siteLatitude);
			linedata.geoCoord["" + item.endSiteName + ""] = [item.siteLongitude, item.siteLatitude];
			markName.push({
				name: item.siteName,
				value: 0
			});
			markgeoCoord["" + item.siteName + ""] = [item.siteLongitude, item.siteLatitude];

		});
	}
	markdata.markPoint.data = markName;
	markdata.geoCoord = markgeoCoord;
	optionMapline.series.push(linedata);
	optionMapline.series.push(markdata);
	myChartMap.setOption(optionMapline);
}

myChartMap.on('click', function(params) {
	if(params.seriesName == '') {
		return;
	} else {
		//联动-----实时更新下面的数据
		if(params.seriesName == '站点') {
			if(params.name.indexOf(">") == -1) {
				console.log(params);
				$("#siteNameGas").html(params.name)
				ajaxGet({
					url: 'home/getGasTrendReport',
					data: {
						groupType: 1,
						siteName: params.name,
						startTime: getNowFormatDate()+'00:00:00',
						endTime: getNowFormatDate()+'23:59:59',
					},
					successFull: function(res) {
						console.log(res);
						if(res.length != 0) {
							var data1 = [];
							var data2 = [];
							var data3 = [];
							$.each(res, function() {
								data1.push(item.outsum);
								data2.push(item.day);
								data3.push({
									value: item.outsum,
									name: item.day
								})
							});
							myChartData.setOption(initEchartsline(data1, data2));
							myChartDataBing.setOption(initChartBing([10, 30], ['50%', 80], data3));
						} else {
							myChartData.setOption(initEchartsline([0, 0, 0, 0, 0, 0, 0], ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']));
							myChartDataBing.setOption(initChartBing([10, 30], ['50%', 80], [{
								value: 0,
								name: "0"
							}]));
						};
						//						useGasToday(params.name);
						//						usePlanToday(params.name);
						//						useGasyeasToday(params.name);
						//						userPlanYeastoday(params.name);
						//						sendGas(params.name);
						//						useGasPosi(params.name);
					},
					errCallBack: function(res) {
						if(res.length != 0) {
							var data1 = [];
							var data2 = [];
							var data3 = [];
							$.each(res, function() {
								data1.push(item.outsum);
								data2.push(item.day);
								data3.push({
									value: item.outsum,
									name: item.day
								})
							});
							myChartData.setOption(initEchartsline(data1, data2));
							myChartDataBing.setOption(initChartBing([10, 30], ['50%', 80], data3));
						} else {
							myChartData.setOption(initEchartsline([0, 0, 0, 0, 0, 0, 0], ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']));
							myChartDataBing.setOption(initChartBing([10, 30], ['50%', 80], [{
								value: 0,
								name: "0"
							}]));
						};
						//						useGasToday(params.name);
						//						usePlanToday(params.name);
						//						useGasyeasToday(params.name);
						//						userPlanYeastoday(params.name);
						//						sendGas(params.name);
						//						useGasPosi(params.name);
					}
				});
				ajaxGet({
					url: 'home/getGasTrendReport',
					data: {
						groupType: 2,
						startTime: years+'-'+months+'-1',
						endTime: years+'-'+months+'-'+days,
						siteName: params.name
					},
					successFull: function(res) {
						if(res.length != 0) {
							var data1 = [];
							var data2 = [];
							var data3 = [];
							$.each(res, function() {
								data1.push(item.outsum);
								data2.push(item.day);
								data3.push({
									value: item.outsum,
									name: item.day
								})
							});
							myChartMonth.setOption(initEchartsline(data1, data2));
							myChartMonthBing.setOption(initChartBing([10, 30], ['50%', 80], data3));
						} else {
							myChartMonth.setOption(initEchartsline([0, 0, 0, 0, 0, 0, 0], ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']));
							myChartMonthBing.setOption(initChartBing([10, 30], ['50%', 80], [{
								value: 0,
								name: "0"
							}]));
						};
						//						useGasToday(params.name);
						//						usePlanToday(params.name);
						//						useGasyeasToday(params.name);
						//						userPlanYeastoday(params.name);
						//						sendGas(params.name);
						//						useGasPosi(params.name);
					},
					errCallBack: function(res) {
						console.log(res);
						if(res.length != 0) {
							var data1 = [];
							var data2 = [];
							var data3 = [];
							$.each(res, function() {
								data1.push(item.outsum);
								data2.push(item.day);
								data3.push({
									value: item.outsum,
									name: item.day
								})
							});
							myChartMonth.setOption(initEchartsline(data1, data2));
							myChartMonthBing.setOption(initChartBing([10, 30], ['50%', 80], data3));
						} else {
							myChartMonth.setOption(initEchartsline([0, 0, 0, 0, 0, 0, 0], ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']));
							myChartMonthBing.setOption(initChartBing([10, 30], ['50%', 80], [{
								value: 0,
								name: "0"
							}]));
						};
						//						useGasToday(params.name);
						//						usePlanToday(params.name);
						//						useGasyeasToday(params.name);
						//						userPlanYeastoday(params.name);
						//						sendGas(params.name);
						//						useGasPosi(params.name);
					}
				})
				ajaxGet({
					url: 'home/getGasTrendReport',
					data: {
						groupType: 3,
						startTime: years + '-1',
						endTime: years + '-12',
						siteName: params.name
					},
					successFull: function(res) {
						console.log(res);
						if(res.length != 0) {
							var data1 = [];
							var data2 = [];
							var data3 = [];
							$.each(res, function() {
								data1.push(item.outsum);
								data2.push(item.day);
								data3.push({
									value: item.outsum,
									name: item.day
								})
							});
							myChartYear.setOption(initEchartsline(data1, data2));
							myChartYearBing.setOption(initChartBing([10, 30], ['50%', 80], data3));
						} else {
							myChartYear.setOption(initEchartsline([0, 0, 0, 0, 0, 0, 0], ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']));
							myChartYearBing.setOption(initChartBing([10, 30], ['50%', 80], [{
								value: 0,
								name: "0"
							}]));
						}

						//						useGasToday(params.name);
						//						usePlanToday(params.name);
						//						useGasyeasToday(params.name);
						//						userPlanYeastoday(params.name);
						//						sendGas(params.name);
						//						useGasPosi(params.name);
					},
					errCallBack: function(res) {
						console.log(res);
						if(res.length != 0) {
							var data1 = [];
							var data2 = [];
							var data3 = [];
							$.each(res, function() {
								data1.push(item.outsum);
								data2.push(item.day);
								data3.push({
									value: item.outsum,
									name: item.day
								})
							});
							myChartYear.setOption(initEchartsline(data1, data2));
							myChartYearBing.setOption(initChartBing([10, 30], ['50%', 80], data3));
						} else {
							myChartYear.setOption(initEchartsline([0, 0, 0, 0, 0, 0, 0], ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']));
							myChartYearBing.setOption(initChartBing([10, 30], ['50%', 80], [{
								value: 0,
								name: "0"
							}]));
						};
						//						useGasToday(params.name);
						//						usePlanToday(params.name);
						//						useGasyeasToday(params.name);
						//						userPlanYeastoday(params.name);
						//						sendGas(params.name);
						//						useGasPosi(params.name);
					}
				})
			}
		}

	}
});

//默认请求展示的站点的数据
function defulatSiteGas(type, siteName) {
	if(type == 1){
		startTime = getNowFormatDate()+'00:00:00';
		endTime = getNowFormatDate()+'23:59:59';
		
	}else if(type == 2){
		startTime = years+'-'+months+'-1';
		endTime = years+'-'+months+'-'+days;
	}else if(type == 3){
		startTime = years + '-1';
		endTime = years+'-12';
	}
	ajaxGet({
		url: 'home/getGasTrendReport',
		data: {
			groupType: type,
			startTime:startTime,
			endTime:endTime,
			siteName: siteName
		},
		successFull: function(res) {
			console.log(res);
			if(res.length != 0) {
				var data1 = [];
				var data2 = [];
				var data3 = [];
				$.each(res, function() {
					data1.push(item.outsum);
					data2.push(item.day);
					data3.push({
						value: item.outsum,
						name: item.day
					})
				});
				if(type == 1) {
					myChartData.setOption(initEchartsline(data1, data2));
					myChartDataBing.setOption(initChartBing([10, 30], ['50%', 80], data3));
				} else if(type == 2) {
					myChartMonth.setOption(initEchartsline(data1, data2));
					myChartMonthBing.setOption(initChartBing([10, 30], ['50%', 80], data3));
				} else if(type == 3) {
					myChartYear.setOption(initEchartsline(data1, data2));
					myChartYearBing.setOption(initChartBing([10, 30], ['50%', 80], data3));
				}

			} else {
				if(type == 1) {
					myChartData.setOption(initEchartsline(data1, data2));
					myChartDataBing.setOption(initChartBing([10, 30], ['50%', 80], [{
						value: 0,
						name: "0"
					}]));
				} else if(type == 2) {
					myChartMonth.setOption(initEchartsline([0, 0, 0, 0, 0, 0, 0], ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']));
					myChartMonthBing.setOption(initChartBing([10, 30], ['50%', 80], [{
						value: 0,
						name: "0"
					}]));
				} else if(type == 3) {
					myChartYear.setOption(initEchartsline([0, 0, 0, 0, 0, 0, 0], ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']));
					myChartYearBing.setOption(initChartBing([10, 30], ['50%', 80], [{
						value: 0,
						name: "0"
					}]));
				}
			}
			//						useGasToday(params.name);
			//						usePlanToday(params.name);
			//						useGasyeasToday(params.name);
			//						userPlanYeastoday(params.name);
			//						sendGas(params.name);
		},
		errCallBack: function(res) {
			if(res.length != 0) {
				var data1 = [];
				var data2 = [];
				var data3 = [];
				$.each(res, function() {
					data1.push(item.outsum);
					data2.push(item.day);
					data3.push({
						value: item.outsum,
						name: item.day
					})
				});
				if(type == 1) {
					myChartData.setOption(initEchartsline(data1, data2));
					myChartDataBing.setOption(initChartBing([10, 30], ['50%', 80], data3));
				} else if(type == 2) {
					myChartMonth.setOption(initEchartsline(data1, data2));
					myChartMonthBing.setOption(initChartBing([10, 30], ['50%', 80], data3));
				} else if(type == 3) {
					myChartYear.setOption(initEchartsline(data1, data2));
					myChartYearBing.setOption(initChartBing([10, 30], ['50%', 80], data3));
				}

			} else {
				if(type == 1) {
					myChartData.setOption(initEchartsline([0, 0, 0, 0, 0, 0, 0], ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']));
					myChartDataBing.setOption(initChartBing([10, 30], ['50%', 80], [{
						value: 0,
						name: "0"
					}]));
				} else if(type == 2) {
					myChartMonth.setOption(initEchartsline([0, 0, 0, 0, 0, 0, 0], ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']));
					myChartMonthBing.setOption(initChartBing([10, 30], ['50%', 80], [{
						value: 0,
						name: "0"
					}]));
				} else if(type == 3) {
					myChartYear.setOption(initEchartsline([0, 0, 0, 0, 0, 0, 0], ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']));
					myChartYearBing.setOption(initChartBing([10, 30], ['50%', 80], [{
						value: 0,
						name: "0"
					}]));
				}
			}
			//						useGasToday(params.name);
			//						usePlanToday(params.name);
			//						useGasyeasToday(params.name);
			//						userPlanYeastoday(params.name);
			//						sendGas(params.name);
		},
	})
}